<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>






<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="ps,后期," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="平时喜欢给自己的照片添加边框，边框包括照片黑色描边、添加阴影、边框留白30px等。由于需要添加边框的照片数量太多，不可能手动一张一张的添加，所以总结了自己的一些使用经验，利用PS的动作记录功能制作了批量处理的脚本，可以为一堆同比例的照片添加边框，效率极高。同时如果你学会使用动作功能，可通过该教程举一反三，对你以后使用ps处理大量文件将会有极大的帮助。   添加边框后的效果">
<meta name="keywords" content="ps,后期">
<meta property="og:type" content="article">
<meta property="og:title" content="摄影后期，用Photoshop动作为照片批量添加边框">
<meta property="og:url" content="http://yoursite.com/2017/05/05/ps_syjj/index.html">
<meta property="og:site_name" content="杂七杂八">
<meta property="og:description" content="平时喜欢给自己的照片添加边框，边框包括照片黑色描边、添加阴影、边框留白30px等。由于需要添加边框的照片数量太多，不可能手动一张一张的添加，所以总结了自己的一些使用经验，利用PS的动作记录功能制作了批量处理的脚本，可以为一堆同比例的照片添加边框，效率极高。同时如果你学会使用动作功能，可通过该教程举一反三，对你以后使用ps处理大量文件将会有极大的帮助。   添加边框后的效果">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/P5010045.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-20-51.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-21-26.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-21-49.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-22-04.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-22-21.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-22-55.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-23-11.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-30-01.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-09-51-36.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-09-49-20.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-34-35.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-44-42.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-05-23-45-35.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-09-32-13.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-10-37-21.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-13-54-52.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-17-39-52.jpg">
<meta property="og:image" content="http://yoursite.com/2017/05/05/ps_syjj/2017-05-06-17-42-03.jpg">
<meta property="og:updated_time" content="2017-05-07T10:54:26.151Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="摄影后期，用Photoshop动作为照片批量添加边框">
<meta name="twitter:description" content="平时喜欢给自己的照片添加边框，边框包括照片黑色描边、添加阴影、边框留白30px等。由于需要添加边框的照片数量太多，不可能手动一张一张的添加，所以总结了自己的一些使用经验，利用PS的动作记录功能制作了批量处理的脚本，可以为一堆同比例的照片添加边框，效率极高。同时如果你学会使用动作功能，可通过该教程举一反三，对你以后使用ps处理大量文件将会有极大的帮助。   添加边框后的效果">
<meta name="twitter:image" content="http://yoursite.com/2017/05/05/ps_syjj/P5010045.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/05/05/ps_syjj/"/>





  <title>摄影后期，用Photoshop动作为照片批量添加边框 | 杂七杂八</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  











  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=1261868868&web_id=1261868868" language="JavaScript"></script>
  </div>






  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">杂七杂八</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">AoloMode 的博客</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/05/ps_syjj/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="韦超">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="杂七杂八">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">摄影后期，用Photoshop动作为照片批量添加边框</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-05T23:58:11+08:00">
                2017-05-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/摄影/" itemprop="url" rel="index">
                    <span itemprop="name">摄影</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <hr>
<p>平时喜欢给自己的照片添加边框，边框包括照片黑色描边、添加阴影、边框留白30px等。由于需要添加边框的照片数量太多，不可能手动一张一张的添加，所以总结了自己的一些使用经验，利用PS的动作记录功能制作了批量处理的脚本，可以为一堆同比例的照片添加边框，效率极高。同时如果你学会使用动作功能，可通过该教程举一反三，对你以后使用ps处理大量文件将会有极大的帮助。</p>
<hr>
<p><span class="img-noborder"><img src="/2017/05/05/ps_syjj/P5010045.jpg" alt=""></span></p>
<p></p><p class="image-caption">添加边框后的效果</p><br><a id="more"></a><p></p>
<div class="note info"><p>上面这张照片最终效果，图片为3:2比例，参数为:</p>
<p><strong>照片有效尺寸: </strong>不包含外边框，尺寸为2000x1333，我用这个尺寸的原因是保存后大小为1m左右，图片质量损失较少，能够保存到QQ空间中不占用大量空间，利于网上传播。<br><strong>照片完整尺寸: </strong>包含外边框，尺寸为2060x1393<br><strong>照片外边框: </strong>60x60，颜色: #ffffff，即纯白色<br><strong>照片描边: </strong>外描边1px，颜色: #000000，即纯黑色<br><strong>照片阴影: </strong>阴影颜色: #000000，混合模式: 正片叠底，不透明度: 100，角度: 120度，距离: 5，扩展: 0，大小: 10</p>
<p>上述参数说明: 这张照片全尺寸为2060x1393，其中有60x60的白色边框，所以上面这张照片的有效部分其实只有2000x1333。</p>
</div>
<blockquote class="blockquote-center"><p><strong>有时候我想多张照片都加上述参数，那么我不可能一张一张的去处理，不然会累死人的，所以Photoshop中的“动作”功能就在这个时候非常有用了。以下是操作步骤: </strong></p>
</blockquote>
<h1 id="制作并使用批处理"><a href="#制作并使用批处理" class="headerlink" title="制作并使用批处理"></a>制作并使用批处理</h1><h2 id="步骤一-记录操作步骤"><a href="#步骤一-记录操作步骤" class="headerlink" title="步骤一: 记录操作步骤"></a>步骤一: 记录操作步骤</h2><p>这一步主要是记录你处理照片的所有过程，保存为一个批处理脚本，这个脚本就可以使用到其他照片中，从而可以批量处理照片，提高效率。(以下提示:如果图片看不清楚，那么请在电脑上浏览并点击图片查看大图)</p>
<p>(1) 在ps的的菜单中找到窗口/动作，或者按快捷Alt+F9打开动作面板，点击右下方的“创建新动作”，名称为“3x2照片添加阴影和边框”，点记录。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-20-51.jpg" alt=""><br>(2) 打开一张照片， 点击照片上的“锁”图标，为照片解锁。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-21-26.jpg" alt=""><br>(3) 点击“创建新图层”按钮<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-21-49.jpg" alt=""><br>(4) 把刚才创建的图层移动到图片下方，这一步目的是要给照片添加外边框，继续看后续步骤你就可以知道。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-22-04.jpg" alt=""><br>(5) 按Ctrl+Alt+I，设置图像大小为2000。这一步作用是把照片尺寸等比缩放为2000x1333比例的。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-22-21.jpg" alt=""><br>(6) 按Ctrl+Alt+C，设置画布大小为2060x1393。仔细看尺寸和上述步骤的对比参数，宽高多出了60px，作用是给照片添加30px的边框。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-22-55.jpg" alt=""><br>(7) 设置前景色为白色#ffffff，选中这个最底部的图层按Alt+Delete给图层填充白色(白边框)。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-23-11.jpg" alt=""><br>(8) 选择照片图层，点击“添加图层样式”按钮选择“描边”。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-30-01.jpg" alt=""><br>(9) 设置描边参数如下，设置好参数后，点“设置为默认值”，点确定。<br><img src="/2017/05/05/ps_syjj/2017-05-06-09-51-36.jpg" alt=""><br>(10) 选择阴影，设置阴影参数如下，设置好参数后，点“设置为默认值”,点确定。<br><img src="/2017/05/05/ps_syjj/2017-05-06-09-49-20.jpg" alt=""><br>(11) 按Ctrl+Shift+S，保存处理的照片到电脑任意位置，然后在弹出的窗口中对“品质”参数设置，我一般设置为“最佳”或者设置为11(只要保证图片在1m左右即可)，然后点确定。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-34-35.jpg" alt=""><br>(12 )按Ctrl+W关闭文件，选择否<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-44-42.jpg" alt=""><br>(13) 最后，点动作面板下方的“停止播放/记录”按钮，对照片的处理步骤已经记录完成。<br><img src="/2017/05/05/ps_syjj/2017-05-05-23-45-35.jpg" alt=""></p>
<div class="note danger"><h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><p>1、在处理照片的过程中，你不消息在某一个步骤中取消了当前的步骤，会导致动作中的记录停止，所以如果发现动作停止，那需要点动作面板下方的“方形(即停止)”按钮继续记录。</p>
<p>2、记录过程中不小心出现操作步骤失误，而动作已经记录下来了，那么点击动作面板下方的“方形”按钮先停止动作记录，然后在动作面板中拖动失误的步骤记录到“垃圾箱(即删除)“按钮，然后点击“圆点”按钮继续记录即可。</p>
</div>
<h2 id="步骤二-批量处理照片"><a href="#步骤二-批量处理照片" class="headerlink" title="步骤二: 批量处理照片"></a>步骤二: 批量处理照片</h2><p>这个步骤是将上述步骤制作好的批处理脚本来批量为照片添加上一步的效果的。</p>
<p>两个地方需要注意，主要是选择照片源文件所在文件夹，然后选择将照片放到哪个文件夹，最后确定，等待处理完成即可。<br><img src="/2017/05/05/ps_syjj/2017-05-06-09-32-13.jpg" alt=""><br>下面是我用这个脚本批量处理一堆照片后的3x2比例的部分照片，完美。<br><img src="/2017/05/05/ps_syjj/2017-05-06-10-37-21.jpg" alt=""></p>
<div class="note info"><p>说明: 这个批处理只适合给3x2比例的照片添加边框，如果你要给其它比例的照片批量添加相框，请自己按照上述步骤的参数创建新的动作即可，思路是相同的，只是参数不同而已了。步骤一样，边框参数你随意调哈。</p>
</div>
<h1 id="创建快捷批处理"><a href="#创建快捷批处理" class="headerlink" title="创建快捷批处理"></a>创建快捷批处理</h1><p>我们可以将上述步骤创建批处理保存为批处理，下次想使用的时候，可以直接将照片或者照片所在文件夹拖动到这个批处理即可。<br><img src="/2017/05/05/ps_syjj/2017-05-06-13-54-52.jpg" alt=""><br>按照下面设置好参数。<br><img src="/2017/05/05/ps_syjj/2017-05-06-17-39-52.jpg" alt=""><br>下图生成了一个exe的批处理程序，需要用的时将照片文件或者照片所在文件夹拖动到这个exe程序上就可以自动批量处理了，很方便。<br><img src="/2017/05/05/ps_syjj/2017-05-06-17-42-03.jpg" alt=""></p>
<h1 id="技巧总结"><a href="#技巧总结" class="headerlink" title="技巧总结"></a>技巧总结</h1><div class="note success"><p>技巧总结：上述的动作记录功能其实就是将你在ps中处理相片的整个步骤都记录下来存为一个批处理文件，方便我们对大量需要重复性的操作步骤进行统一批量处理，高效方便。所以你看了上述教程，你完全可以举一反三，使用ps的动作功能制作更多的批处理脚本，比如批量将一堆不同格式的文件转换成jpg格式，或者批量为一堆图片添加某些效果等等。</p>
</div> 
<hr>
<p>说明：您有什么问题可以通过以下方式和我沟通。</p>
<p>联系方式：<br>邮箱：weiyi552306@qq.com<br>QQ：695747333</p>
<hr>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ps/" rel="tag"># ps</a>
          
            <a href="/tags/后期/" rel="tag"># 后期</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/05/07/sh_computer/" rel="next" title="我要配电脑，我要学习！！！">
                <i class="fa fa-chevron-left"></i> 我要配电脑，我要学习！！！
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/04/houqi-content/" rel="prev" title="个人摄影后期部分心得记录">
                个人摄影后期部分心得记录 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="韦超" />
          <p class="site-author-name" itemprop="name">韦超</p>
           
              <p class="site-description motion-element" itemprop="description">工作、学习、生活中的点滴！</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">32</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#制作并使用批处理"><span class="nav-text">制作并使用批处理</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#步骤一-记录操作步骤"><span class="nav-text">步骤一: 记录操作步骤</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#注意事项"><span class="nav-text">注意事项</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#步骤二-批量处理照片"><span class="nav-text">步骤二: 批量处理照片</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#创建快捷批处理"><span class="nav-text">创建快捷批处理</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#技巧总结"><span class="nav-text">技巧总结</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">韦超</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (search_path.endsWith("json")) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  

  

</body>
</html>
